home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / PCI Driver Development Kit / • Samples / Open Firmware Samples / Minimal sample / NCRUI.of < prev   
Encoding:
Text File  |  1996-11-14  |  4.6 KB  |  116 lines  |  [TEXT/MPS ]

  1.  
  2. \ Open Firmware FCode driver for the NCR 8250S PCI-SCSI Card
  3. \
  4. \ by Monte Benaresh -- October 19, 1994
  5. \
  6. \ Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  7. \
  8.  
  9. \ ** This is a slight modification of NCR.of, which shows how you would use 
  10. \    it with the Open Firmware User Interface.  To download this code,
  11. \    type dl at the OF UI prompt, then send file (make sure it's using text tool),
  12. \    type <ctrl-d> to end the download.
  13. \      Or, you can copy and paste instead of send file.
  14.  
  15. \ This is a minimal FCode driver which simply provides identifying information
  16. \ in its device node, and creates a property in its device node which contains
  17. \ the runtime driver to be loaded into the Mac system heap by the Expansion Bus
  18. \ Manager.  It also creates children nodes specific to SCSI bus devices.
  19.  
  20. \ push arguments on the stack for pci-header:
  21. \    *** THESE MUST MATCH THE CONFIG REGISTERS FOR YOUR    ***
  22. \    *** FCODE TO BE RECOGNIZED BY OPEN FIRMWARE            ***
  23. \    vendor #, device #, class-code = SCSI bus controller
  24.  
  25. \ ** tokenizer, pci-header, fcode-version2 are tokenizer words
  26. \ tokenizer[  hex  1000 0003 010000  decimal ]tokenizer
  27. \ pci-header                \ generate proper PCI image header
  28.  
  29. \    fcode-version2        \ generate proper FCode header (within PCI image)
  30.  
  31. \ ** This is meant to be downloaded to the machine when it's
  32. \    in the state after a reset-all
  33.  
  34.     \ Push arguments that describe where we want a new device node to be created
  35.     0 0 " D" " /bandit"
  36.     
  37.     \ We create a package (node), and open an instance of it
  38.     begin-package             
  39.  
  40. \ ** Here begins the common code in NCR.of
  41.     " AAPL,NCR8250S" device-name                        \ Apple is card vendor
  42.     " scsi" device-type
  43.     " 8250S" model
  44.  
  45. \ generate a "reg" property which lists our configuration space at the start of
  46. \ our assigned space, with 0 size (as required by the PCI Binding Supplement)
  47.  
  48.     0 0 my-space encode-phys
  49.         0 encode-int 0 encode-int encode+ encode+                    \ config space
  50.  
  51. \ The next entry is for the onboard ROM memory space, and is
  52. \ if you are using encode-file to encapsulate your runtime
  53. \ driver.
  54.  
  55.     0 0 my-space h# 02000030 or encode-phys
  56.         0 encode-int h# 00008000 encode-int encode+ encode+            \ ROM space
  57.         encode+
  58.     0 0 my-space h# 02000014 or encode-phys
  59.         0 encode-int h# 00000100 encode-int encode+ encode+            \ memory space
  60.         encode+ " reg" property
  61.  
  62. \ generate a "power-consumtion" property which lists standby and full-on power
  63. \ consumtion for various power rails in microwatts; if we don't create this
  64. \ property, Open Firmware will create one by filling in the "unspecified" rail
  65. \ entries from the PRSNT pins (since we know our power consumption, we fill the
  66. \ "unspecified" entries with zeros)
  67.  
  68.     0 encode-int 0 encode-int encode+                                \ "unspecified"
  69.     d# 7500000 encode-int d# 7500000 encode-int encode+ encode+        \ +5V
  70.     0 encode-int 0 encode-int encode+ encode+                        \ +3V
  71.     d# 8100000 encode-int d# 8100000 encode-int encode+ encode+        \ I/O power
  72.     \ remaining entries are 0 and can be omitted
  73.     \ 0 encode-int 0 encode-int encode+ encode+                        \ reserved
  74.     " power-consumption" property
  75.  
  76.  
  77. \ the following properties will be automatically generated for this card:
  78. \    "has-fcode"
  79. \    "vendor-id" - from PCI configuration register
  80. \    "device-id" - from PCI configuration register
  81. \    "revision-id" - from PCI configuration register
  82. \    "class-code" - from PCI configuration register
  83. \    "interrupts" - from PCI configuration register
  84. \    "min-grant" - from PCI configuration register
  85. \    "max-latency" - from PCI configuration register
  86. \    "devsel-speed" - from PCI configuration register
  87. \    "fast-back-to-back" - from PCI configuration register
  88. \    "assigned-addresses"
  89.  
  90. \ we don't need to define any methods here; there is enough information for the
  91. \ runtime driver to be able to locate the card, but a complete FCode implementation
  92. \ would provide boot-time I/O services
  93.  
  94.  
  95. \ include an image of the runtime driver, and have it assigned as the value of a
  96. \ property that the Expansion Bus Manager will read at startup
  97.  
  98. \ the name of the property takes the form, "driver,<company>,<osname>,<isa>"
  99. \ NOTE:    in the following example, the given <osname> (for Macintosh System 7)
  100. \        is preliminary and subject to change
  101.  
  102. \ ** Here ends the common code in NCR.of
  103.  
  104. \ ** encode-file, fcode-end, pci-end are tokenizer words 
  105. \    encode-file runtime.bin   " driver,AAPL,MacOS,PowerPC" property
  106.  
  107.  
  108. \    fcode-end            \ terminate normal FCode
  109. \ pci-end                    \ complete the PCI image
  110.  
  111. \ ** now close it off
  112.     assign-addresses     \ Tell the USER INTERFACE to emulate OpenFirmware address assignment
  113.     make-properties        \ This gives us the standard automatically generated PCI properties
  114.     .properties         \ This just displays some informative stuff
  115.     end-package         \ This terminates this package (node) definition
  116.